﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using CNLTHD_GoogleMapAPI_DAO;
using CNLTHD_GoogleMapAPI_DTO;
using CNLTHD_GoogleMapAPI.UserControl;
using System.Web.UI.WebControls;

namespace CNLTHD_GoogleMapAPI
{
    public partial class CapNhatDiaDiem : System.Web.UI.Page
    {
        public bool dangNhap = false;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["NguoiDung"] != null)
                dangNhap = true;
            tenDD.Text = Request.QueryString["ten"];
            kinhDo.Text = Request.QueryString["lng"];
            viDo.Text = Request.QueryString["lat"];
            if (!IsPostBack)
            {
                List<LoaiDiaDiem> list = LoaiDiaDiemDAO.LayDaySachLoaiDiaDiem();
                loaiDD.DataSource = list;
                loaiDD.DataTextField = "TenLoaiDiaDiem";
                loaiDD.DataValueField = "MaLoaiDiaDiem";
                loaiDD.DataBind();
            }
        }

        protected void bnt_Onclick(object sender, EventArgs e)
        {
            Double DkinhDo = Double.Parse(Request.QueryString["lng"]);
            Double DviDo = Double.Parse(Request.QueryString["lat"]);
			int maDiaDiem = int.Parse(Request.QueryString["maDiaDiem"]);
            String StenDD = Request.QueryString["ten"];
            NguoiDung nd = (NguoiDung)Session["NguoiDung"];
            DiaDiemDAO.CapNhat(maDiaDiem, DkinhDo, DviDo, nd.MaNguoiDung, Int32.Parse(loaiDD.SelectedValue), StenDD, ghiChu.Text);
            this.Response.Redirect("MyMap.aspx");
        }
    }
}